from pathlib import Path
import os,sys
folder = sys.argv[1]
folder = Path(folder.strip())
assert  folder.exists()
def gen_():
    ans=[]
    while True:
        search = "202"
        result = list(folder.rglob(f'*{search}*'))
        if not result:
            # print("在{floder}下未找到关键字名称的{search}的文件夹或文件")
            continue
        else:
            result_folder=[]
            result_file=[]
            for i in (result):
                if i.is_dir():
                    result_folder.append(i)
                else:
                    result_file.append(i)
            if result_folder:
                # print("查找包含关键字{search}的文件夹有：")
                for i in (result_folder):
                    ans.append(i)
                    # print(i)
                break
    
            if result_file:
                print("查找包含关键字{search}的文件有：")
                for i in (result_file):
                    print(i)
                    
                break
    return ans
asn=gen_()
for a in asn:
    p=str(a)
    os.system(f"./utils/mapper_from_images {p} ../camera.yml  0.08 ARUCO A -ref 26  1")
    os.system(f"python3 ../py/gencloud.py   {p}")
    os.system(f"python3 ../py/moveboard.py  {p} 0.02")
    # os.system(f"python3 ../py/cal.py ")
    # print(str(a))